package com.zhuangjie.order.controller;


import com.zhaungjie.base.conduit.R;
import com.zhuangjie.base.constant.ModuleSecurityNames;
import com.zhuangjie.order.dto.OrderEvaluateSubmitDTO;
import com.zhuangjie.order.service.OrderService;
import com.zhuangjie.order.vo.OrderForUserEvaluateVO;
import com.zhuangjie.security.annotations.PublicAPI;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 评价 前端控制器
 * </p>
 *
 * @author zhuangjie
 * @since 2023-11-24
 */
@RestController
@RequestMapping("/order-evaluate")
public class OrderEvaluateController {

    @Autowired
    private OrderService orderService;



    @ApiOperation("获取订单评价需要的VO")
    @GetMapping("/for-user-evaluate")
    @PublicAPI(modules = {ModuleSecurityNames.USER})
    public R getOrderForUserEvaluate(@RequestParam("orderId") Long orderId) {
        return R.require(OrderForUserEvaluateVO.class, orderService.getOrderForUserEvaluate(orderId));
    }

    @ApiOperation("提交订单评价")
    @PostMapping("/submit")
    @PublicAPI(modules = {ModuleSecurityNames.USER})
    public R submit(@Valid @RequestBody OrderEvaluateSubmitDTO orderEvaluateSubmitDTO) {
        return R.capture(()->orderService.submitOrderEvaluate(orderEvaluateSubmitDTO));
    }



}

